package util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Conexion {

	private static String url = "";
	private static Connection cn = null;
	
	static {
		try {
			Class.forName("com.ibm.as400.access.AS400JDBCDriver");
			url = "jdbc:as400://192.168.1.7/SPEED400TC;prompt=false";
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} 
	}
	
	public static void conectar(){
		try {
			cn = DriverManager.getConnection(url, "dparreno", "m140202");
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public static Connection obtenerConexion() {
		return cn;
	}

	public static void desconectar(){
		try {
			cn.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			try {
				cn.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		
	}
}